home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 64 / Mac Magazin CD 64.iso / Updates / RealPC_Update109 / RealPC Upgrade Disk / SWUPDATE.BAT < prev    next >
Encoding:
DOS Batch File  |  1999-11-30  |  15.3 KB  |  435 lines

  1. @echo off
  2. @if not "%8" == "" echo %8
  3. rem [
  4. rem    Name:        u.swupdate.bat
  5. rem
  6. rem    Derived from:    (original)
  7. rem
  8. rem    Author:        David Lillie
  9. rem
  10. rem    Created on:    Sep 1996
  11. rem
  12. rem    Sccs ID:    @(#)u.swupdate.bat    1.52 02/01/98
  13. rem
  14. rem    Coding Stds:    
  15. rem
  16. rem    Purpose:    To upgrade a SoftWindows hard disk container file.
  17. rem            This is called automatically.
  18. rem
  19. rem    Parameters:    1    host OS type i.e. "mac" or "unix"
  20. rem            2    new serial number (8 hex digits)
  21. rem            3    old serial number (8 hex digits)
  22. rem            4    Host System name
  23. rem            5    Host System release
  24. rem            6    Host System version
  25. rem            7    Host System hardware type
  26. rem            8    On/Off argument for echo
  27. rem            9    Drive letter for "WIN95" setup directory.
  28. rem
  29. rem    Copyright 1997-1999 Insignia Solutions PLC. All rights reserved.
  30. rem ]
  31.  
  32.  
  33. rem Set path to upgrade utils (for an automatic upgrade)
  34. if exist d:\insignia\ibatch.exe path d:\;d:\insignia;%path%
  35.  
  36. rem Check to see if we have a valid first parameter
  37. if "%1"=="" goto manstamp
  38. rem Set up host OS environment variable
  39. ibatch swupdate_host tolower %1
  40. if "%swupdate_host%"=="unix" goto CheckSerial
  41. if "%swupdate_host%"=="mac" goto CheckSerial
  42. goto manstamp
  43.  
  44. :CheckSerial
  45. rem Check that we have the right number of parameters
  46. if "%9"=="" goto manstamp
  47.  
  48.  
  49. rem  Determine whether this is a newly-installed Intel OS
  50. set OSIsNew=0
  51. ibatch swupdate_NewOS = 0x%2 & 0xF000 #lx
  52. ibatch swupdate_OldOS = 0x%3 & 0xF000 #lx
  53. itest 0x%3 ">=" 0xF0000000
  54. if errorlevel 1 itest "%swupdate_OldOS%" "!=" "%swupdate_NewOS%"
  55. if errorlevel 1 set OSIsNew=1
  56.  
  57.  
  58. rem  Make copy of serial number which we might modify
  59. set new_sn=%2
  60.  
  61. rem  Detect new OS for cases where bootstrap couldn't - modifies new_sn.
  62. call osvcheck new_sn %new_sn%
  63.  
  64. rem  Determine whether this is a newly-installed Intel OS
  65. set OSIsNew=0
  66. ibatch swupdate_NewOS = 0x%new_sn% & 0xF000 #lx
  67. ibatch swupdate_OldOS = 0x%3       & 0xF000 #lx
  68. itest 0x%3 ">=" 0xF0000000
  69. if errorlevel 1 itest "%swupdate_OldOS%" "!=" "%swupdate_NewOS%"
  70. if errorlevel 1 set OSIsNew=1
  71.  
  72.  
  73. rem Get language code from serial number.
  74. ibatch langNO string "%new_sn%" 2 2
  75. ibatch langNO tolower "%langNO%"
  76.  
  77. rem Determine which language extension to use
  78. call dec_lang langID %langNO%
  79. if not "%langID%" == "" goto GotLang
  80.  
  81. rem  Unknown language in requested serial number.
  82. rem  Try to detect the language from the hard disk.
  83. call findlang langNO
  84.  
  85. rem  Insert the language code into the serial number
  86. ibatch sn_head string "%new_sn%" 0 2
  87. ibatch sn_tail string "%new_sn%" 4 4
  88. set new_sn=%sn_head%%langNO%%sn_tail%
  89. set sn_head=
  90. set sn_tail=
  91.  
  92. call dec_lang langID %langNO%
  93. if not "%langID%" == "" goto GotLang
  94.  
  95. echo Unrecognised language on drive C:
  96. pause
  97. goto reboot
  98.  
  99. :GotLang
  100.  
  101. rem  Ensure we have 'our' directory.
  102. if not exist c:\insignia\nul md c:\insignia
  103.  
  104. rem  If there is no upgrade history, extract what we can from
  105. rem  the last upgrade log (if there was one).
  106. rem  We are interested in the two top batch files and the serial numbers of
  107. rem  the disks (searching for "-" finds the serial nos independent of language).
  108. if exist c:\insignia\uphist.log goto nonewhist
  109. if not exist c:\insignia\up.log goto nonewhist
  110. find /i /n "swupdate" c:\insignia\up.log >> c:\insignia\uphist.log
  111. find /i /n "w95once"  c:\insignia\up.log >> c:\insignia\uphist.log
  112. find /i /n "-"        c:\insignia\up.log >> c:\insignia\uphist.log
  113. :nonewhist
  114.  
  115. rem  Create log file afresh for each upgrade. Append to the history file.
  116. echo %0 %1 %2 %3 %4 %5 %6 %7 %8 %9    > c:\insignia\up.log
  117. echo. | date                >>c:\insignia\up.log
  118. echo. | time                >>c:\insignia\up.log
  119. vol c:                    >>c:\insignia\up.log
  120. vol d:                    >>c:\insignia\up.log
  121. echo %0 %1 %2 %3 %4 %5 %6 %7 %8 %9    >>c:\insignia\uphist.log
  122. echo. | date                >>c:\insignia\uphist.log
  123. echo. | time                >>c:\insignia\uphist.log
  124. vol c:                    >>c:\insignia\uphist.log
  125. vol d:                    >>c:\insignia\uphist.log
  126.  
  127. ver                    >>c:\insignia\up.log
  128.  
  129. rem  Get interesting part of old serial number in lower case.
  130. ibatch old_swinv string %3 0 2
  131. ibatch old_swinv tolower %old_swinv%
  132.  
  133.  
  134. if not "%swupdate_host%" == "unix" goto no_esave
  135.  
  136. rem    Load FSA drivers and save user's E: drive setup. We need to restore
  137. rem    it because "net use" changes the user's configuration.
  138. rem     We need to frig the DOS version for devlod on Windows 95 disks.
  139.  
  140. dosver 6 0  d:\insignia\devlod.com d:\insignia\host.sys >>c:\insignia\up.log
  141. fsadrive >>c:\insignia\up.log
  142. net use e: | ibatch swupdate_edir string 0 0
  143.  
  144. rem    Obtain selected keyboard defaults file if any.
  145. rem    We do this here because we need to re-use FSA drive E: later.
  146. rem    (Having bypassed config.sys, the effective LASTDRIVE is E:)
  147.  
  148. net use e: /d>>c:\insignia\up.log
  149. net use e: $SWINHOME/local>>c:\insignia\up.log
  150. copy d:\unixonly\keybdef.unx c:\insignia\keyboard.def                >>c:\insignia\up.log
  151. if exist e:\selected\keyboard.def copy e:\selected\keyboard.def c:\insignia    >>c:\insignia\up.log
  152. net use e: /d>>c:\insignia\up.log
  153.  
  154. :no_esave
  155.  
  156. rem Ensure that critical files are writable (we make some read-only)
  157. if exist c:\insignia\*.*        attrib -r c:\insignia\*.* /s
  158. if exist c:\windows\pif\suspend.pif    attrib -r c:\windows\pif\suspend.pif
  159.  
  160. rem  Copy this file to drive C for manual updates.
  161. copy d:\swupdate.bat c:\insignia        >>c:\insignia\up.log
  162.  
  163. if not exist c:\windows\system.ini goto dosonly
  164. rem Test for Windows 95
  165. if exist c:\windows\ios.ini goto rawwin95
  166. rem Test for Windows For Workgroups
  167. if exist c:\windows\clipsrv.exe goto rawwfw
  168. rem Test for Windows 3.11 (NB emm386.exe exists on G:\ and C:\windows in
  169. rem a split setup).
  170. if exist c:\windows\emm386.exe goto rawwin311
  171.  
  172. :dosonly
  173. set swupdate_os=dos
  174. set space_needed=5000
  175. checkspc %space_needed%
  176. if not errorlevel 1 goto no_space
  177.  
  178. echo Adding Insignia drivers to DOS on drive C: ...
  179.  
  180. rem Remove obsolete stuff
  181. call delfiles list c:\windows c:\windows\system %swupdate_os% %1 %OSIsNew%
  182.  
  183. rem Copy files.
  184. xcopy /y d:\insignia        c:\insignia    >>c:\insignia\up.log
  185. xcopy /y d:\%1only        c:\insignia    >>c:\insignia\up.log
  186. if not exist c:\nwclient\nul md    c:\nwclient    >>c:\insignia\up.log
  187. xcopy /s /y d:\nwclient        c:\nwclient    >>c:\insignia\up.log
  188. c:
  189. cd \insignia
  190.  
  191. rem Only overwrite config.sys and autoexec.bat if it is a clean (CD2) hard disk
  192. if not "%old_swinv%" == "f0" goto no_dosbatch
  193.  
  194. set dos_type=msdos
  195. if not exist c:\dos\find.exe goto no_find
  196. ver | find "PC DOS" >nul
  197. if not errorlevel 1 set dos_type=pcdos
  198. :no_find
  199.  
  200. call dosbatch %1 %langID% %dos_type%
  201. :no_dosbatch
  202.  
  203. rem call d:\%1.bat dos c:\windows\system %langID% %4 %5 %6 %7
  204. goto purestamp
  205.  
  206. :rawnowin
  207. echo No version of Windows installed on C:
  208. pause
  209. goto reboot
  210.  
  211. :rawwfw
  212. set swupdate_os=wfw311
  213. set swupdate_os_name=Windows for Workgroups 3.11
  214. goto win31_and_wfw
  215.  
  216. :rawwin311
  217. set swupdate_os=win311
  218. set swupdate_os_name=Windows 3.11
  219. :win31_and_wfw
  220.  
  221. if not "%swupdate_host%" == "unix" goto win31hdf
  222.  
  223. rem Detect split setup (the default for Unix Swin 2.0)
  224. rem    If user.exe is present in G:\ and absent from C:\windows\system then
  225. rem    this is a split setup. If it exists in both places then it means that
  226. rem    either win2c.bat has been run, or it was put there ad hoc; either way
  227. rem    it implies a hard disk only setup.
  228. rem    Because we have bypassed config.sys and autoexec.bat, we need to set up
  229. rem    FSA and find the fsa windows directory explicitly. Furthermore we are
  230. rem    constrained to drive E: because we cannot execute a LASTDRIVE command.
  231.  
  232. if exist c:\windows\system\user.exe goto win31hdf
  233. net use e: /d>>c:\insignia\up.log
  234. net use e: $SWINHOME/windows>>c:\insignia\up.log
  235.  
  236. if exist e:\user.exe goto win31fsa
  237. net use e: /d>>c:\insignia\up.log
  238. goto rawnowin
  239.  
  240. :win31hdf
  241. set space_needed=5000
  242. checkspc %space_needed%
  243. if not errorlevel 1 goto no_space
  244. echo Adding Insignia drivers to %swupdate_os_name% on drive C: ...
  245. set swupdate_windir=c:\windows
  246. set swupdate_sysdir=c:\windows\system
  247. goto win31both
  248.  
  249. :win31fsa
  250. set space_needed=4000
  251. checkspc %space_needed%
  252. if not errorlevel 1 goto no_space
  253. echo Adding Insignia drivers to %swupdate_os_name% on FSA drive $SWINHOME/windows ...
  254. set swupdate_windir=e:
  255. set swupdate_sysdir=e:
  256.  
  257. :win31both
  258.  
  259. rem Remove obsolete stuff
  260. call delfiles list %swupdate_windir% %swupdate_sysdir% %swupdate_os% %1 %OSIsNew%
  261.  
  262. rem Copy files.
  263. xcopy /y d:\insignia c:\insignia    >>c:\insignia\up.log
  264. xcopy /y d:\%1only   c:\insignia    >>c:\insignia\up.log
  265.  
  266. call copywinf d:\insignia\for_win    %swupdate_windir%    >>c:\insignia\up.log
  267. call copywinf d:\%1only\for_win        %swupdate_windir%    >>c:\insignia\up.log
  268. call copywinf d:\insignia\for_w31    %swupdate_windir%    >>c:\insignia\up.log
  269. call copywinf d:\%1only\for_w31        %swupdate_windir%    >>c:\insignia\up.log
  270. xcopy /y d:\insignia\for_win\system    %swupdate_sysdir%    >>c:\insignia\up.log
  271. xcopy /y d:\%1only\for_win\system     %swupdate_sysdir%    >>c:\insignia\up.log
  272. xcopy /y d:\insignia\for_w31\system    %swupdate_sysdir%    >>c:\insignia\up.log
  273. xcopy /y d:\%1only\for_w31\system    %swupdate_sysdir%    >>c:\insignia\up.log
  274. if not exist c:\nwclient\nul md        c:\nwclient        >>c:\insignia\up.log
  275. xcopy /s /y d:\nwclient            c:\nwclient        >>c:\insignia\up.log
  276. if exist d:\%langID%only\for_win\nul call copywinf d:\%langID%only\for_win %swupdate_windir% >>c:\insignia\up.log
  277. c:
  278. cd \insignia
  279.  
  280. rem Only overwrite config.sys and autoexec.bat if it is a clean (CD2) hard disk
  281. if "%old_swinv%" == "f0" call dosbatch %1 %langID% win31
  282.  
  283. call w31batch %swupdate_windir% %swupdate_sysdir% %swupdate_os% %1 %langID% %3
  284. call d:\%1.bat win31 %swupdate_sysdir% %langID% %4 %5 %6 %7
  285. if "%swupdate_host%" == "unix" net use e: /d>>c:\insignia\up.log
  286. goto purestamp
  287.  
  288. :rawwin95
  289. ver | find "4." | ibatch swupdate_os_name string 0 10
  290. ibatch swupdate_os string "%swupdate_os_name%" 8 2
  291. set swupdate_os=win%swupdate_os%
  292.  
  293. set space_needed=10000
  294. checkspc %space_needed%
  295. if not errorlevel 1 goto no_space
  296.  
  297. echo Adding Insignia drivers to %swupdate_os_name% ...
  298.  
  299. rem Remove obsolete stuff
  300. call delfiles list c:\windows c:\windows\system %swupdate_os% %1 %OSIsNew%
  301.  
  302. rem Copy files.
  303. xcopy /y d:\insignia        c:\insignia    >>c:\insignia\up.log
  304. xcopy /y d:\%1only        c:\insignia    >>c:\insignia\up.log
  305. xcopy /s /y d:\insignia\for_win    c:\windows    >>c:\insignia\up.log
  306. xcopy /s /y d:\%1only\for_win    c:\windows    >>c:\insignia\up.log
  307. xcopy /s /y d:\insignia\for_w95    c:\windows    >>c:\insignia\up.log
  308. xcopy /s /y d:\%1only\for_w95    c:\windows    >>c:\insignia\up.log
  309. if not exist c:\nwclient\nul md    c:\nwclient    >>c:\insignia\up.log
  310. xcopy /s /y d:\nwclient        c:\nwclient    >>c:\insignia\up.log
  311. if exist d:\%langID%only\for_win\nul xcopy /s /y d:\%langID%only\for_win c:\windows >>c:\insignia\up.log
  312. c:
  313. cd \insignia
  314.  
  315. rem Only overwrite config.sys and autoexec.bat if it is a clean (CD2) hard disk
  316. if "%old_swinv%" == "f0" call dosbatch %1 %langID% win95
  317.  
  318. call w95batch %swupdate_host% %new_sn% %3 %4 %5 %6 %7 %swupdate_os%
  319.  
  320. rem  Construct reg file to add the runonce entry and
  321. rem  repair the installation source path (BCN 5506).
  322. echo REGEDIT4>c:\insignia\runonce.reg
  323.  
  324. echo.>>c:\insignia\runonce.reg
  325. echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce]>>c:\insignia\runonce.reg
  326. echo "IS_Customize"="c:\\insignia\\w95once.bat %swupdate_host% %new_sn% %3 %4 %5 %6 %7 %8 %langID%">>c:\insignia\runonce.reg
  327.  
  328. rem  Need to repair setup source path for:
  329. rem    a. New pre-installed disk.
  330. rem    b. Mac SoftWindows95 1.0 disk.
  331. set W95SourcePath=%9:\\%swupdate_os%
  332. ibatch W95SourcePath toupper "%W95SourcePath%"
  333. if not "%old_swinv%" == "f0" if not "%W95SourcePath%" == "D:\\WIN95" goto noSourcePath
  334.  
  335. if not "%swupdate_host%" == "unix" goto no_unix95
  336. rem  On Unix SoftWindows95, setup files are optionally installed on
  337. rem  $SWINHOME/win95 (or $SWINHOME/win98) which is mounted on G:
  338. net use e: /d>>c:\insignia\up.log
  339. net use e: $SWINHOME>>c:\insignia\up.log
  340. if exist e:\%swupdate_os%\mini.cab set W95SourcePath=G:\\
  341. net use e: /d>>c:\insignia\up.log
  342. :no_unix95
  343. rem  The setup files may still be on disk, in which case we should use them.
  344. if exist c:\windows\options\cabs\mini.cab set W95SourcePath=C:\\WINDOWS\\OPTIONS\\CABS
  345.  
  346. echo.>>c:\insignia\runonce.reg
  347. echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup]>>c:\insignia\runonce.reg
  348. echo "SourcePath"="%W95SourcePath%">>c:\insignia\runonce.reg
  349. :noSourcePath
  350. set W95SourcePath=
  351.  
  352. regedit c:\insignia\runonce.reg            >>c:\insignia\up.log
  353. echo.>>c:\insignia\up.log
  354.  
  355. rem  Set up likely paths for Windows 95/98 setup files.
  356. ibatch swupdate_os_upper toupper %swupdate_os%
  357. echo WIN_SOURCE_DIR=%swupdate_os_upper%>c:\insignia\mrumod.def
  358. keybconf c:\insignia\mrumod.def d:\insignia\mrumod.spt c:\insignia\mrumod.spt    >>c:\insignia\up.log
  359. mruedit  c:\insignia\mrumod.spt                            >>c:\insignia\up.log
  360.  
  361. if not "%swupdate_os%" == "win95" goto noESDI
  362. rem  Early versions of SoftWindows95 1.0 reported the wrong PnP ID for the
  363. rem  Insignia ESDI controller. We patch the correct ID into the registry here,
  364. rem  to prevent Windows displaying a reboot prompt during the upgrade.
  365. set enum_key=HKEY_LOCAL_MACHINE\Enum
  366. set eb_esdi_key=[%enum_key%\BIOS\*ISL060A]
  367. regedit /e c:\insignia\temp.reg %enum_key%    >>c:\insignia\up.log
  368. type c:\insignia\temp.reg | find "%eb_esdi_key%" | ibatch found_key string 0 0
  369. if not "%found_key%" == "%eb_esdi_key%" regedit d:\ins_esdi.reg    >>c:\insignia\up.log
  370. echo.>>c:\insignia\up.log
  371. del c:\insignia\temp.reg    >>c:\insignia\up.log
  372.  
  373. rem  And add the Windows 95 specific UGD entries
  374. type c:\insignia\w95only.ugd    >> c:\insignia\win95.ugd
  375. :noESDI
  376.  
  377. call d:\%1.bat win95 c:\windows\system %langID% %4 %5 %6 %7
  378. goto purestamp
  379.  
  380. :purestamp
  381. echo Update complete.
  382. rem
  383. rem Restore user's FSA drive
  384. if not "%swupdate_edir%" == "" net use %swupdate_edir%>>c:\insignia\up.log
  385. rem
  386. rem Update disk version number
  387. rem
  388. debug <d:\upcode.inp d:\empty %new_sn% >nul
  389. goto reboot
  390.  
  391. :manstamp
  392. rem  swupdate has been activated manually
  393. rem Log the manual upgrade to the history file.
  394. echo Manual upgrade activated. OS=%1, Extra Parameters %2 %3 %4 %5 %6 %7 %8 %9 >>c:\insignia\uphist.log
  395.  
  396. rem
  397. rem Set the first two digits of serial number to F1 and reboot.
  398. rem This will force an upgrade with the correct parameters
  399. debug <c:\insignia\upman.inp >nul
  400. goto reboot
  401.  
  402. :reboot
  403. rem
  404. rem Restore user's FSA drive
  405. if not "%swupdate_edir%" == "" net use %swupdate_edir%>>c:\insignia\up.log
  406. rem
  407. rem Reboot
  408. rem
  409. debug <c:\insignia\reboot.inp >nul
  410. rem We should not get here, but if we do..
  411. goto End
  412.  
  413. :no_space
  414. cls
  415. set sn=%space_needed%
  416. echo **************************************************************************
  417. echo *                                                                        *
  418. echo *                              WARNING                                   *
  419. echo *                                                                        *
  420. echo * There is not enough free space on your C: drive to perform the         *
  421. echo * upgrade.  You need a minimum of %sn%000 bytes free.                    *
  422. echo *                                                                        *
  423. echo * To increase the available free space, either:                          *
  424. echo * delete any unwanted files and restart; or increase the size            *
  425. echo * of your C: drive as described in the product documentation.            *
  426. echo *                                                                        *
  427. echo **************************************************************************
  428. goto End
  429.  
  430. :End
  431. rem
  432. rem Restore user's FSA drive
  433. if not "%swupdate_edir%" == "" net use %swupdate_edir%>>c:\insignia\up.log
  434.  
  435.